package hu.vpszd.services.impl;

import static org.junit.Assert.*;
import hu.vpszd.entities.customer.Address;
import hu.vpszd.entities.customer.AddressCard;
import hu.vpszd.entities.customer.Customer;
import hu.vpszd.entities.customer.IDCard;
import hu.vpszd.entities.customer.TaxCard;
import hu.vpszd.entities.transaction.ExistingLoanDebt;
import hu.vpszd.entities.transaction.Income;
import hu.vpszd.entities.transaction.LoanApplication;
import hu.vpszd.services.OfferService;

import java.util.Date;

import org.junit.Test;

class OfferServiceImplTest {

	private OfferService os = new OfferServiceImpl();

	@Test
	public void test() {
		LoanApplication loanApplication = new LoanApplication();

		// loanApplication.set;
		loanApplication.setLoanTypeName("loanTypeName_1");

		Customer customer = new Customer();
		customer.setLastName("Varga");
		customer.setFirstName("Péter");
		customer.setBirthCountry("Magyarország");
		customer.setBirthplace("Balassagyarmat");
		// insert into Customer (id, city, country, houseNumber, state,
		// streetName, zipCode, ACexpirationDate, ACidentityNumber,
		// ACissuingAuthority, ACvalidFrom, birthCountry, birthFirstName,
		// birthLastName, birthday, birthplace, account_ID, citizenship,
		// education, emailAddress, firstName, gender, ICexpirationDate,
		// ICidentityNumber, ICissuingAuthority, ICvalidFrom, lastName,
		// maritalStatus, mobilePhone, otherPhone, residency, TCexpirationDate,
		// TCidentityNumber, TCissuingAuthority, TCvalidFrom, wiredPhone) values
		// (1, 'Rétság', 'Magyarország', 30, 'Nógrád', 'Rózsavölgy', 2651,
		// '2020-01-01 00:00:00', '000001aa', 'asd', '2013-01-01 00:00:00',
		// 'Magyarország', 'Péter', 'Varga', '1989-08-17 00:00:00',
		// 'Balassagyarmat', null, 'Magyar', 'Egyéb', 'vp.05@hotmail.com',
		// 'Péter', 0, '2020-01-01 00:00:00', '000001aa', 'asd', '2013-01-01
		// 00:00:00', 'Varga', 'Egyedülálló', '+36203845157', '', 'Bérlő',
		// '2020-01-01 00:00:00', '0123456789', 'asd', '2013-01-01 00:00:00',
		// '+1234567890');
		
		AddressCard addressCard = new AddressCard();
//		Date date = new Date(2014,04,06,13,58,30);
//		addressCard.setACexpirationDate(date);
		addressCard.setACidentityNumber("000001aa");
//		addressCard.setACissuingAuthority("asd");
//		addressCard.setACvalidFrom(date);
		customer.setAddressCard(addressCard);
		customer.setIdCard(new IDCard());
		customer.getIdCard().setICidentityNumber("000001aa");
		customer.setTaxCard(new TaxCard());
		customer.getTaxCard().setTCidentityNumber("0123456789");
		loanApplication.setEducation("Egyetem");
		loanApplication.setMaritalStatus("Egyedülálló");
		loanApplication.setAddress(new Address());
		loanApplication.getAddress().setCity("Rétság");
		loanApplication.getAddress().setCountry("Magyarország");
		loanApplication.getAddress().setHouseNumber(30);
		loanApplication.getAddress().setState("Nógrád");
		loanApplication.getAddress().setStreetName("Rózsavölgy");
		loanApplication.getAddress().setZipCode(2651);
		loanApplication.setResidency("Tulajdonos");
		loanApplication.setEmailAddress("vp.05@hotmail.com");
		loanApplication.setMobilePhone("+36203845157");
		loanApplication.setWiredPhone("+36011234567");
		
		Income income = new Income();
		income.setCompanyAddress("asd utca");
		income.setCompanyName("asd kft");
		income.setId(1L);
		income.setIncomeAmount(100000);
		income.setIncomeType("Alkalmazotti");
		income.setRank("Felsövezetö");
		income.setRegistrationNumber("Cégjegyzékszám");
		income.setTaxNumber("Adószám");
		Date lengthOfEmployement = new Date();
		income.setLengthOfEmployement(lengthOfEmployement);
		loanApplication.getIncomes().add(income);
		
		income = new Income();
		income.setCompanyAddress("asd utca");
		income.setCompanyName("asd kft");
		income.setId(2L);
		income.setIncomeAmount(300000);
		income.setIncomeType("Alkalmazotti");
		income.setRank("Felsövezetö");
		income.setRegistrationNumber("Cégjegyzékszám");
		income.setTaxNumber("Adószám");
		lengthOfEmployement = new Date();
		income.setLengthOfEmployement(lengthOfEmployement);
		loanApplication.getIncomes().add(income);
		
		ExistingLoanDebt existingLoanDebt = new ExistingLoanDebt();
		existingLoanDebt.setCurrecy("Forint");
		existingLoanDebt.setExistingLoanDebtAmount(100000);
		existingLoanDebt.setMonthlyInstallment(10000);
		Date loanExpiration = new Date();
		existingLoanDebt.setLoanExpiration(loanExpiration);
		loanApplication.getExistingLoanDebts().add(existingLoanDebt);
		
		existingLoanDebt = new ExistingLoanDebt();
		existingLoanDebt.setCurrecy("Forint");
		existingLoanDebt.setExistingLoanDebtAmount(100000);
		existingLoanDebt.setMonthlyInstallment(10000);
		loanExpiration = new Date();
		existingLoanDebt.setLoanExpiration(loanExpiration);
		loanApplication.getExistingLoanDebts().add(existingLoanDebt);
		
		loanApplication.setId(1L);
		loanApplication.setLoanAmountByBank(900000);
		loanApplication.setDurationByBank(60);
		loanApplication.setInstallment(15000);
		loanApplication.setInterest(1.1);
		
		os.createOffer(loanApplication, customer);
	}


}
